<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>&lt;sys/sem.h&gt;</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_009_336">&nbsp;</a>NAME</h4><blockquote>
sys/sem.h - semaphore facility
</blockquote><h4><a name = "tag_000_009_337">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;sys/sem.h&gt;
</code>
</pre>
</blockquote><h4><a name = "tag_000_009_338">&nbsp;</a>DESCRIPTION</h4><blockquote>
The &lt;<b>sys/sem.h</b>&gt; header defines the following constants and
structures.
<p>
Semaphore operation flags:
<dl compact>

<dt>SEM_UNDO<dd>
Set up adjust on exit entry.

</dl>
<p>
Command definitions for the function
<i><a href="semctl.html">semctl()</a></i>:
<dl compact>

<dt>GETNCNT<dd>
Get
<b>semncnt</b>.

<dt>GETPID<dd>
Get
<b>sempid</b>.

<dt>GETVAL<dd>
Get
<b>semval</b>.

<dt>GETALL<dd>
Get all cases of
<b>semval</b>.

<dt>GETZCNT<dd>
Get
<b>semzcnt</b>.

<dt>SETVAL<dd>
Set
<b>semval</b>.

<dt>SETALL<dd>
Set all cases of
<b>semval</b>.

</dl>
<p>
The structure
<b>semid_ds</b>
contains the following members:
<pre>
<code>
struct ipc_perm    sem_perm  operation permission structure
unsigned short int sem_nsems number of semaphores in set
time_t             sem_otime last <i>semop</i>^) time
time_t             sem_ctime last time changed by <i>semctl</i>()
</code>
</pre>
<p>
The
<b>pid_t</b>,
<b>time_t</b>,
<b>key_t</b>
and
<b>size_t</b>
types are defined as described in
<i><a href="systypes.h.html">&lt;sys/types.h&gt;</a></i>.
<p>
A semaphore is represented by an anonymous
structure containing the following members:
<pre>
<code>
unsigned short int semval    semaphore value
pid_t              sempid    process ID of last operation
unsigned short int semncnt   number of processes waiting for <b>semval</b>
                             to become greater than current value
unsigned short int semzcnt   number of processes waiting for <b>semval</b>
                             to become 0
</code>
</pre>
<p>
The structure
<b>sembuf</b>
contains the following members:
<pre>
<code>
unsigned short int sem_num   semaphore number
short int          sem_op    semaphore operation
short int          sem_flg   operation flags
</code>
</pre>
<p>
The following are declared as functions and may also be defined
as macros.
Function prototypes must be provided for use with an ISO C
compiler.
<pre>
<code>
int   <a href="semctl.html">semctl</a>(int, int, int, ...);
int   <a href="semget.html">semget</a>(key_t, int, int);
int   <a href="semop.html">semop</a>(int, struct sembuf *, size_t);
</code>
</pre>
<p>
In addition, all of the symbols from
<i><a href="sysipc.h.html">&lt;sys/ipc.h&gt;</a></i>
will be defined when this header is included.
</blockquote><h4><a name = "tag_000_009_339">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_009_340">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_009_341">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="semctl.html">semctl()</a></i>,
<i><a href="semget.html">semget()</a></i>,
<i><a href="semop.html">semop()</a></i>,
<i><a href="systypes.h.html">&lt;sys/types.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
